package com.group.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: MPconfig
 * Package: com.one.mpconfig
 * Description:
 *
 * @Author zys
 * @Create 2024/10/30 17:46
 * @Version 1.0
 * @since JDK17
 */
@Configuration  // 标记为配置类
public class MPConfig {

    @Bean  // 注册拦截器
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); // 拦截器
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());   // 分页插件
        mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());   // 乐观锁插件
        return mybatisPlusInterceptor;
    }
}
